﻿using Box.Transient.FreeSql.Repository;
using FreeSql;
using ManaSky.Common.Model;
using ManaSky.Entity;
using ManaSky.IRepository;
using ManaSky.Repository.Bases;
using ManaSky.SSO.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ManaSky.Repository
{
    /// <summary>
    /// 用户信息仓储
    /// </summary>
    public class SysUsersRepository : ShareRepository<sys_user>, ISysUsersRepository
    {
        public SysUsersRepository(IFreeSql fsql, UnitOfWorkManager unitOfWork, IAuth auth) : base(fsql, unitOfWork, auth)
        {
        }
        /// <summary>
        /// 修改用户最后登陆时间
        /// </summary>
        /// <param name="sys_Users"></param>
        /// <returns></returns>
        public async Task<bool> UpdUserLasLoginTime(int userId)
        {
            var i = await this.UpdateDiy.Where(t=>t.Id == userId).Set(t => new { LastLoginTime = DateTime.Now, UptDtt = DateTime.Now }).ExecuteAffrowsAsync();
            //var i = await this.Orm.Update<sys_user>().Set(t => t.LastLoginTime == DateTime.Now).ExecuteAffrowsAsync();
            return i > 0;
        }
    }
}
